Skip to content

Fix personal nodriver evaluate normalization#120

Merged
genz27 merged 3 commits intoTheSmallHanCat:mainfrom
zy6p:fix-personal-nodriver-evaluate-normalization
Apr 17, 2026
Merged

Fix personal nodriver evaluate normalization#120
genz27 merged 3 commits intoTheSmallHanCat:mainfrom
zy6p:fix-personal-nodriver-evaluate-normalization

Conversation

@zy6p
Copy link
Copy Markdown
Contributor

@zy6p zy6p commented Apr 14, 2026

Summary

  • always normalize nodriver tab.evaluate() results in personal captcha mode
  • execute fingerprint extraction JS as an IIFE so the object is actually returned
  • fixes personal score-test DOM parsing and restores full browser fingerprint extraction

Reproduction

I reproduced this against current upstream main locally with BrowserCaptchaService.get_custom_score() on https://antcpt.com/score_detector/.

Before this patch:

  • token acquisition succeeded
  • verify_result ended as success=false with source=antcpt_dom_timeout
  • get_last_fingerprint() only had the fallback UA/lang because the full object was not parsed

Root cause:

  • _tab_evaluate() only normalized results when return_by_value=True, but most callers do not pass that flag and receive nodriver's serialized object-entry structure instead of plain Python values
  • _extract_tab_fingerprint() passed an uninvoked arrow function (() => { ... }) so nodriver did not return the intended object payload

After this patch:

  • verify_result.success=true
  • score=0.9
  • full fingerprint fields are returned (user_agent, accept_language, sec_ch_ua, sec_ch_ua_mobile, sec_ch_ua_platform)

Validation

  • python3 -m py_compile src/services/browser_captcha_personal.py
  • local personal get_custom_score() reproduction before/after patch on upstream main

if return_by_value:
return self._normalize_nodriver_evaluate_result(result)
return result
return self._normalize_nodriver_evaluate_result(result)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove return_by_value check is not good, change default value above to True is better

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8a8f5c4: I kept the return_by_value switch, changed its default to true, and only normalize when return_by_value is enabled. This preserves the non-value path while making existing evaluate callers return plain Python values by default.

@zy6p
Copy link
Copy Markdown
Contributor Author

zy6p commented Apr 14, 2026

Updated per review: _tab_evaluate now keeps the return_by_value switch, but defaults it to true so the nodriver evaluate result is normalized by default for existing internal callers. The non-value path is still preserved if it is needed later.

@genz27 genz27 merged commit deb8f19 into TheSmallHanCat:main Apr 17, 2026
2 checks passed
Copy link
Copy Markdown
Collaborator

@genz27 genz27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已同步 main,冲突已解决,并完成本地测试验证。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants